﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using secondhand.L2busslogic;
using secondhand.L1database;
using secondhand.L3object;
using System.IO;

namespace secondhand.L4view
{
    public partial class master_check2 : System.Web.UI.Page
    {
        public static string ID;
        public static string saleTime;
        public static string salerName;
        public static string masterCheck;
        protected void Page_Load(object sender, EventArgs e)
        {
            goodsOB mydd = new goodsOB();
            mydd = goodsBL.Getwordsingle((Session["goodsName"].ToString()));
            if (mydd.master_check == "审核通过" || mydd.master_check == "审核未通过")
            {
                Button1.Visible = false;
                Button2.Visible = false;
                Label10.Visible = true;
            }
            if (mydd.master_check == "未审核")
            {
                Button1.Visible = true;
                Button2.Visible = true;
                Label10.Visible = false;
            }
            if (mydd.goods_name.Trim() == "访问数据库不成功！")
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('没有该商品 ');</script>");
                return;
            }
            ID = mydd.goods_ID;
            saleTime = mydd.sale_time;
            salerName = mydd.saler_name;
            masterCheck = mydd.master_check;
            Label6.Text = mydd.goods_name;
            Label7.Text = mydd.goods_type;
            Label8.Text = mydd.goods_price;
            Label9.Text = mydd.goods_describe;
            Image1.ImageUrl = mydd.goods_picture;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            goodsOB mydd = new goodsOB();
            mydd.goods_ID = ID;
            mydd.goods_name = Label6.Text;
            mydd.goods_type = Label7.Text;
            mydd.goods_price = Label8.Text;
            mydd.goods_describe = Label9.Text;
            mydd.goods_picture = Image1.ImageUrl;
            mydd.sale_time = saleTime;
            mydd.saler_name = salerName;
            mydd.master_check = "审核未通过";
            if (!goodsBL.Savemark(mydd))
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('审核成功 ');</script>");
                Response.Redirect("~/L4View/master_check.aspx");
                return;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('审核不成功 ');</script>");
                Response.Redirect("~/L4View/master_check.aspx");
                return;
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            goodsOB mydd = new goodsOB();
            mydd.goods_ID = ID;
            mydd.goods_name = Label6.Text;
            mydd.goods_type = Label7.Text;
            mydd.goods_price = Label8.Text;
            mydd.goods_describe = Label9.Text;
            mydd.goods_picture = Image1.ImageUrl;
            mydd.sale_time = saleTime;
            mydd.saler_name = salerName;
            mydd.master_check = "审核通过";
            if (goodsBL.Savemark(mydd))
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('审核成功!');{location.href='master_check.aspx'}</script>");
                return;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('审核不成功!');{location.href='master_check.aspx'}</script>");
                return;
            }
        }
    }
}